1. Field
Example embodiments relate to a synchronous script lazy loading system, and more particularly, to a system and method of synchronous script lazy loading adapted to separate a script source code into modules for storage and lazily load each module at the time when the module is used so that the modules are synchronously loaded into a memory, and a computer-readable recording medium having recorded thereon a program for executing the synchronous script lazy loading method.
2. Description of the Related Art
Today, the extensive use of the Internet has led to rapid advancements of wireless mobile communication technologies. Use of mobile terminals such as mobile phones, personal digital assistants (PDAs), and hand-held computers allows one to search for information on the Internet with little limitation of time and space. Smart phones collectively refer to mobile phones that combine the functionality of a mobile phone with features of a computer. While retaining the functionality of a mobile phone, smart phones also support additional features such as a PDA function, an Internet function, and a moving image reproduction function. Furthermore, by supporting a wireless Internet function, smart phones may act as a terminal for supporting email, web browsing, fax, banking, and/or game functions. In this way, an increasingly large number of people are web surfing or web browsing by using smart phones that offer various features.
JavaScript is a scripting language developed by Netscape Communications Corp. in the U.S. and is used in various environments. As a representative example, JavaScript is being used as a scripting language that is executed by a web browser such as Internet Explorer developed by Microsoft Corp. In this case, JavaScript may be inserted into a standard hypertext markup language (HTML) document to create an interactive web page. In particular, with the recent improvement in performance of computers and smart phones, JavaScript is being used in a wide range of applications since programs such as animation or simple computations may be implemented by using JavaScript without sending any special request to a server.
However, recently, as more diverse interface features and functions have been added to a web service for user convenience, the size of an associated script file (e.g., JavaScript file) has increased. Fetching, parsing, and loading a script file having such an increased size into a memory for execution results in long loading times for web pages. In particular, due to long loading times, smart phone users experience a significant degradation in performance compared to users of other types of devices because a fast response time is of high importance for smart phones having a small bandwidth. Thus, such a slow response time when using smart phones inconveniences users and results in user dissatisfaction.
In one example, referring to FIG. 1A illustrating a portion of an example HTML file implemented by using a conventional scripting method, a JavaScript file is included in a portion indicated as ‘A’ by using a <script> tag. A web browser receives an HTML file and sequentially interprets the HTML file by reading a JavaScript file inserted between the <script> tags via a communication network, parsing all JavaScript modules in the JavaScript file, and loading the parsed JavaScript modules into a memory, which is then followed by interpretation of a JavaScript file with a <script> tag in a next line. Thus, the above operations may cause a delay before a web page is displayed on a screen. Furthermore, it is unnecessary to parse all unused JavaScript modules in the HTML file and load them into a memory.
To overcome these problems, one of proposed conventional approaches is to improve execution speed of a web application on a mobile terminal by loading a compiled JavaScript file into a memory so that the compiled JavaScript file is already stored in the memory before running the web application. However, this approach is limited to only a web application in which a script file is repeatedly used after being loaded. It may be difficult to apply the approach uniformly to web surfing in which users browse a plurality of web pages each including different script modules in a single web service through links. Even if this approach is applied, long initial loading times and a waste of memory space due to all script files residing in the memory may result. Furthermore, when a web browser accesses a plurality of web pages provided by a web service, the web browser repeats parsing of script modules in a web page and loading the parsed script modules into a memory even if script files that have previously been read are already stored in a cache and do not need to be read again whenever the web page changes. Thus, to improve performance of the all script modules used in a web service for each web page need to be separated and loaded as needed instead of storing all the script modules in a single file.
Thus, as described above, a lazy loading method has been proposed in which script modules used in a web service are split according to function into a plurality of files and the files are loaded as needed for use. However, a drawback of a conventional lazy loading technique is that many requests may be made at a time according to a script module used in a web page because files are loaded when a specific script module is needed. Another drawback is that the conventional lazy loading technique requires a complicated asynchronous design using a callback function because the conventional lazy loading technique loads script files asynchronously. Furthermore, if a plurality of script modules depend on each other, it is necessary to design a module in consideration of the dependency therebetween. In one example, if a method “someMethod” within an object “util” is used, a code has to be implemented by fetching a module including the object “util” over a network, loading the module, and thereafter using the module in a callback function. The code should be written similar to an example JavaScript code implemented by using a conventional asynchronous JavaScript lazy loading method shown in FIG. 1B.
Asynchronous lazy loading using a callback function requires understanding of asynchronous operations and consideration of the time at which other codes are executed, thereby increasing the complexity of a development process. Furthermore, to apply the asynchronous lazy loading to already existing web pages, previously written source codes have to be modified to a great extent.
Thus, there is a need for a synchronous lazy loading technique that allows loading of each script module into a memory when the script module is needed, thus solving the above-described problems of conventional asynchronous script lazy loading.